package com.treasure.mall.biz.entity.order;

import com.treasure.mall.biz.entity.Base2PO;
import com.treasure.mall.biz.entity.embeddable.Product;
import com.treasure.mall.biz.entity.user.MerchantPO;
import com.treasure.mall.zbq.common.constant.Constant;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author allan
 * @version 1.0.0
 * @date 2020/7/23
 */
@Entity
@Table(name = "zb_settlement_bill")
@Setter
@Getter
@Cacheable(false)
public class SettlementBillPO extends Base2PO {
    @Id
    @Column(name = "id")
    private String id;
    @Column(name = "order_item_id")
    private Long orderItemId;
    @Column(name = "sub_order_id")
    private String subOrderId;
    /**
     * 关联的商品
     */
    private Product product;
    /**
     * 平台服务费比例
     */
    @Column(name = "service_rate", scale = 3, precision = 6)
    private BigDecimal serviceRate;
    /**
     * 结算金额
     */
    @Column(name = "amount", scale = 2, precision = 10)
    private BigDecimal amount;
    /**
     * 结算商家
     */
    @ManyToOne
    @JoinColumn(name = "merchant_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
    private MerchantPO merchantPO;
    /**
     * 转正时间
     */
    @Column(name = "convert_time", columnDefinition = Constant.DATE_COLUMN_DEFINITION)
    private LocalDateTime convertTime;
    /**
     * 是否失效（售后）
     */
    @Column(name = "is_invalidate")
    private boolean invalidate;
    /**
     * 是否转正
     */
    @Column(name = "is_converted")
    private boolean converted;
}
